﻿using System;

using AMC.SubstitutionCache.Rendering;
using AMC.SubstitutionCache.Services;

namespace AMC.SubstitutionCache.Drivers
{
    public abstract class SubstitutionDriverBase
    {
        protected static readonly Func<dynamic, SubstitutionContext, bool> EditorTemplateShapeLocator = (shape, context) =>
        {
            return shape != null && shape.EditorTemplateShapeType == context.ShapeType;
        };

        protected static Func<dynamic, SubstitutionContext, bool> DisplayTemplateShapeLocator = (shape, context) =>
        {
            return shape != null && shape.DisplayTemplateShapeType == context.ShapeType;
        };

        protected string GetEditorTemplateShapeType(string templateName)
        {
            return ShapeHelper.GetShapeTypeForTemplate("EditorTemplate", templateName);
        }

        protected string GetDisplayTemplateShapeType(string templateName)
        {
            return ShapeHelper.GetShapeTypeForTemplate("DisplayTemplate", templateName);
        }
    }
}